Repository navigation
Fix pointer tests on 64-bit hosts - #28
Firat17aze wants to merge 1 commit into
Conversation
by-ae
left a comment
There was a problem hiding this comment.
Ran this locally with native 64-bit GCC. I had to comment out set(LWPRINTF_TEST_ARCH 32) in tests/test_basic/cmake.cmake for that, because without gcc-multilib the forced -m32 doesn't link:
- develop (920135e): 158 passed, 3 failed, all of them the
%pcases - this branch: 151 passed, 0 failed
- this branch merged into current develop (merges cleanly): 161 passed, 0 failed
The 64-bit expectations match what case 'p' does in lwprintf.c, zero-padded to sizeof(uintptr_t) * 2 digits. <stdint.h> is already included at the top of test_basic.c, so UINTPTR_MAX is defined there and the #if can't quietly fall back to the 32-bit branch.
One thing: cmake.cmake still sets LWPRINTF_TEST_ARCH 32, and the workflow installs gcc-multilib, so CI builds with -m32 and only ever runs the #else branch. The new 64-bit expectations only run in local builds: the Win64-Debug preset, a non-GCC compiler like the AppleClang run in the description, or GCC with that line removed. Now that the test handles both widths, it may be worth dropping set(LWPRINTF_TEST_ARCH 32) (and the comment above it) so the native GCC job covers the 64-bit path. Or keep it and add a second test config without it, if you want both widths checked in CI.
Problem
The pointer-format tests hard-code 32-bit output. On a 64-bit host where the compiler cannot use the suite's GCC-only
-m32path,%pcorrectly emits 16 hexadecimal digits and all three pointer assertions fail.Fix
Select the expected pointer width from
UINTPTR_MAX. The existing 32-bit expectations remain unchanged, while 64-bit hosts now check the leading-zero padding produced for a full-width pointer.Validation
cd tests && python3 test.py --github: 151 passed, 0 failed after the change.git diff --check: passed.LLMs were used for review and code generation in some parts of this pull request.